﻿<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<title>hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body, html,#container {width: 100%;height: 100%;overflow: hidden;margin:0;}
</style>
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>

</head>
<body scroll="no" bgcolor="#FFFFFF">
    <div id="container">
    </div>
	
	<script type="text/javascript">
   
    

    // 复杂的自定义覆盖物
    function ComplexCustomOverlay(point, text, mouseoverText) {
        this._point = point;
        this._text = text;
        this._overText = mouseoverText;
    }
    ComplexCustomOverlay.prototype = new BMap.Overlay();
    ComplexCustomOverlay.prototype.initialize = function (map) {
        this._map = map;
        var div = this._div = document.createElement("div");
        div.style.position = "absolute";
        div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
        div.style.backgroundColor = "#FF83FA";
        div.style.border = "2px solid #FFFFFF";
        div.style.color = "white";
        div.style.height = "18px";
        div.style.padding = "2px";
        div.style.lineHeight = "18px";
        div.style.whiteSpace = "nowrap";
        div.style.MozUserSelect = "none";
        div.style.fontSize = "12px"
        var span = this._span = document.createElement("span");
        div.appendChild(span);
        span.appendChild(document.createTextNode(this._text));
        var that = this;

        var arrow = this._arrow = document.createElement("div");
        arrow.style.background = "url(http://map.baidu.com/fwmap/upload/r/map/fwmap/static/house/images/label.png) no-repeat";
        arrow.style.position = "absolute";
        arrow.style.width = "11px";
        arrow.style.height = "10px";
        arrow.style.top = "22px";
        arrow.style.left = "10px";
        arrow.style.overflow = "hidden";
        div.appendChild(arrow);

        div.onmouseover = function () {
            this.style.backgroundColor = "#6BADCA";
            this.style.borderColor = "#FFFFFF";
            this.getElementsByTagName("span")[0].innerHTML = that._overText;
            arrow.style.backgroundPosition = "0px -20px";
        }

        div.onmouseout = function () {
            this.style.backgroundColor = "#FF83FA";
            this.style.borderColor = "#FFFFFF";
            this.getElementsByTagName("span")[0].innerHTML = that._text;
            arrow.style.backgroundPosition = "0px 0px";
        }

        map.getPanes().labelPane.appendChild(div);

        return div;
    }
    ComplexCustomOverlay.prototype.draw = function () {
        var map = this._map;
        var pixel = map.pointToOverlayPixel(this._point);
        this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
        this._div.style.top = pixel.y - 30 + "px";
    }


var pointsList = [
	{ "Longitude":121.507837, "Latitude": 31.288236,  "Time": "13:39", "Description": "土木学院院庆" },
	{ "Longitude": 121.506837, "Latitude": 31.289236,  "Time": "12:39", "Description": "大学生联盟足球赛决赛" },
	{ "Longitude": 121.506837, "Latitude": 31.286236,  "Time": "15:39", "Description": "城市发展论坛" },
	{ "Longitude": 121.507837, "Latitude": 31.287236, "Time": "16:39", "Description": "波鸿饮食节活动" }
 ];
var points = [];


	function addMarker(map,point1, time, des) {
        var mouseoverTxt = time+": "+des;
        var myCompOverlay = new ComplexCustomOverlay(point1, mouseoverTxt, mouseoverTxt);
        map.addOverlay(myCompOverlay);
    }

    
        var map = new BMap.Map("container");            // 创建Map实例
        var point = new BMap.Point(121.506837,31.289236);    // 创建点坐标
        map.centerAndZoom(point, 14);                     // 初始化地图,设置中心点坐标和地图级别。
	    map.enableScrollWheelZoom();

		for (var i = 0; i < pointsList.length; i++) {
			addMarker(map,new BMap.Point(pointsList[i].Longitude, pointsList[i].Latitude), pointsList[i].Time, pointsList[i].Description);
			points.push(new BMap.Point(pointsList[i].Longitude, pointsList[i].Latitude));
		}


	
	   
	    map.setViewport(points);
	


</script>

</body>
</html>
